﻿using ClockInLearning.Db;
using ClockInLearning.Impl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ClockInLearning.Tools
{
    public static class AuthHelper
    {
        public static T GetUserInfoByToken<T>(this AppDbContext context) where T : IUserInfo
        {
            var tokenInfo = CallContext.GetData("token") as TokenInfo;
            var userInfo = context.UserInfos.Where(x => x.Id == tokenInfo.UserId).First().SimpleMapTo<T>();
            return userInfo;
        }
    }
}
